<%-- 
    Document   : ShowProject
    Created on : 27/11/2010, 04:04:41 PM
    Author     : Rainiero
--%>
<%@page import="Gui.*"%>
<%@page import="ServiceInterface.IFacade"%>
<%@page import="DataModel.*"%>
<%@page import="Proxy.ProxySAFP"%>
<%

    String header = GuiHelper.GetInstance().GetHeader();
    String footer = GuiHelper.GetInstance().GetFooter();

    IFacade facade = new ProxySAFP().getServiceInterface();

    int projectId = RequestHelper.GetProjectId(request);

    //Se maneja todo como strings pues se tienen metodos encargados de dar formato consistente
    //a los diversos tipos de datos
    String name = "", description = "", objectives = "", country = "", organization = "";
    String startDate = "", endDate = "";
    String projectOfficer = "";
    String initialBudget = "", actualBudget = "", bankAccount = "";
    String creationDate = "";
    String status = "", type = "";

    String projectOfficerChange = "";

    if(projectId != -1)
    {
        Project project = facade.GetProject(projectId);
        if(project != null)
        {
            if(project.getType() == Enums.ProjectType.Project)
                type = "l proyecto";
            else type = "la solicitud";

            GuiHelper guiHelper = GuiHelper.GetInstance();

            name = project.getName();
            description = project.getProjectDescription();
            objectives = project.getProjectObjectives();
            country = project.getCountryName();
            organization = guiHelper.GetOrganizationLink(project.getOrganization());
            startDate = guiHelper.GetFormattedDate(project.getInitialDate());
            endDate = guiHelper.GetFormattedDate(project.getEndingDate());
            projectOfficer = guiHelper.GetPersonText(project.getProjectOfficial());
            initialBudget = guiHelper.GetCurrencyText(project.getInitialBudget());
            actualBudget = guiHelper.GetCurrencyText(project.getActualBudget());
            bankAccount = project.getBankAccount();
            creationDate = guiHelper.GetFormattedDate(project.getCreationDate());
            status = guiHelper.GetProjectStatus(project.getState());

            boolean canChangeProjectOfficer = project.getType() == Enums.ProjectType.Project;
            //TODO: Implementar seguridad para ver si puede cambiar al oficial
            if(canChangeProjectOfficer)
            {
                projectOfficerChange = "<td>";
                projectOfficerChange += String.format("   <button onclick=\"window.location = '../AMD/ChangeProjectOfficer.jsp?project=%1$s'\">Cambiar oficial de proyecto</button>", projectId);
                projectOfficerChange += "</td>";
            }
        }
    }
    //TODO: Ver si en ocasiones se debe desplegar responsable de organizacion en vez de oficial de proyecto
    //o si en ocasiones se deben desplegar ambos
    //TODO: Desplegar cronograma y desembolsos

%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Datos de<%= type %> <%= name %></title>
        <script language="JavaScript" src="../../calendar/calendar_us.js" type="text/javascript"></script>
        <link rel="stylesheet" href="../../calendar/calendar.css">
        <link rel="stylesheet" type="text/css" href="../Styles/safp.css" />
    </head>
    <body>
        <%= header %>
        <h1><%= name %></h1>
        <form method="post" name="form1" action="" >
            <h2>Información General</h2>
            <table>
                <tr>
                    <td class="label">Nombre:</td>
                    <td class="data">
                        <input type="text" name="txtName" size="30" style="font-size:12pt"/>
                    </td>
                </tr>
                <tr>
                    <td class="label">País anfitrión:</td>
                    <td class="data">
                        <select name="cmbCountry" size="1"></select>
                    </td>
                </tr>
                <tr>
                    <td class="label">Fecha de inicio:</td>
                    <td class="data">
                        <input type="text" name="txtInitDate">
                        <script language="JavaScript" type="text/javascript">
                        new tcal ({'formname': 'form1', 'controlname': 'txtInitDate' });
                        </script>
                    </td>
                </tr>
                <tr>
                    <td class="label">Fecha de finalización:</td>
                    <td class="data">
                        <input type="text" name="txtEndDate">
                        <script language="JavaScript" type="text/javascript">
                            new tcal ({'formname': 'form1', 'controlname': 'txtEndDate' });
                        </script>
                    </td>
                </tr>
                <tr>
                    <td class="label">Presupuesto inicial:</td>
                    <td class="label">
                        <input type="text" name="txtBudget" size="30" style="font-size:12pt"/>
                   </td>
                </tr>
                <tr>
                    <td class="label">Cuenta bancaria:</td>
                    <td class="label">
                        <input type="text" name="txtAccount" size="30" style="font-size:12pt"/>
                   </td>
                </tr>
            </table>
            <h2>Descripción</h2>
            <textarea name="txtDescription" rows="15" cols="90">
            </textarea>
            <h2>Objetivos</h2>
            <textarea name="txtObjectives" rows="15" cols="90">
            </textarea>
            <h2>Responsables del proyecto</h2>
            <table border="1" align="center">
                <tr>
                    <th>Organización</th>
                    <th>Responsable</th>
                    <th>Eliminar</th>
                </tr>
            </table>
            <p class="footerText">Creado en <%= creationDate %></p>
            <%= footer %>
        </form>
    </body>
</html>
